//
//  jvm.h
//  iCodeMacRun
//
//  Created by Andrew Barry on 26/04/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#include <JavaVM/jni.h>

struct LoadedCode
{
	unsigned char *code;
	int codeLength;
	unsigned char *linkMap;
	int linkLength;
};

@class JavascriptProject;

@interface jvm : NSObject {
	@public JNIEnv* env;

	jclass yuicompressor;
	jmethodID compressJS;
	
	jobject compilerObject;
}
+(jvm *) instance;

-(void)startupJava;
-(NSString *) compressJavascript: (NSString *) script;
-(void) startCompilation: (BOOL) forRelease;
-(void) startDirectCompilation: (BOOL) forRelease;
-(void) dumpLinkMap;
-(struct LoadedCode *) getFullCodeForProject: (JavascriptProject *) project;

-(bool) parseJavascript: (NSString *) script forSource: (NSString *) name forProject: (JavascriptProject *) project;
-(bool) compileFunction: (NSString *) script withName: (NSString *) fnname forSource: (NSString *) name forControl: (NSString *) ctlName forEvent: (NSString *) eventName forProject: (JavascriptProject *) project;
-(bool) compileJavascript: (NSString *) path forProject: (JavascriptProject *) project;
-(bool) compileAddFile: (NSString *) path forProject: (JavascriptProject *) project;
@end
